﻿using Fabrication.Tests.TestClasses;
using NUnit.Framework;

namespace Fabrication.Tests
{
    [TestFixture]
    public class enum_properties
    {
        [Test]
        public void should_return_default_for_enum_with_a_default_value()
        {
            var builtItem = new FabricationScope().Generate<SinglePropertyClass<EnumWithDefaultValues>>();

            Assert.That(builtItem.Value, Is.EqualTo(EnumWithDefaultValues.Unknown));
        }

        [Test]
        public void should_return_lowest_value_for_enum_without_a_default_value()
        {
            var builtItem = new FabricationScope().Generate<SinglePropertyClass<EnumWithCustomValues>>();

            Assert.That(builtItem.Value, Is.EqualTo(EnumWithCustomValues.Value));
        }

        [Test]
        public void should_return_default_equivalent_for_enum_with_no_values()
        {
            var builtItem = new FabricationScope().Generate<SinglePropertyClass<EnumWithNoValue>>();

            Assert.That(builtItem.Value, Is.EqualTo((EnumWithNoValue)0));
        }

        [Test]
        public void should_handle_rules_for_enums()
        {
            var builtItem = new FabricationScope().Setup<SinglePropertyClass<EnumWithDefaultValues>>()
                .For(x => x.Value).Use(EnumWithDefaultValues.Value1)
                .Generate();

            Assert.That(builtItem.Value, Is.EqualTo(EnumWithDefaultValues.Value1));
        }
    }
}
